@include('admin._include.header')
<body style="background: #fff">

<div class="layui-fluid">
    <div class="layui-card">

        <div class="layui-card-body">

            <form action="" class="layui-form">
                <div class="layui-form-item">

                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input  id="order_sn" placeholder="请输入订单号" autocomplete="off" class="layui-input"/>
                        </div>
                        <button type="button" class="layui-btn" id="search">确定</button>
                    </div>

                    <div class="layui-inline">
                        <label class="layui-form-label">订单状态</label>
                        <div class="layui-input-inline">
                            <select name="status" lay-verify="required" lay-filter="status" lay-search="">
                                <option value="">请选择订单状态</option>
                                <option value="1">未支付</option>
                                <option value="2">已支付</option>

                            </select>
                        </div>
                    </div>

                </div>
            </form>
                <table lay-filter="order_table" class="layui-table" lay-data="{height:'full-155',cellMinWidth:95,url:'{{url('order/partner-list')}}', page:true,id:'order_table',defaultToolbar:[]}">
                    <thead>
                    <tr>
                        <th lay-data="{field:'id', align:'center',width:80}">ID</th>
                        <th lay-data="{field:'order_sn',align:'center'}">订单编号</th>
                        <th lay-data="{toolbar:'#toolbarUser',width:160,align:'center'}">用户</th>
                        <th lay-data="{field:'amount',align:'center',width:120}">支付金额</th>
                        <th lay-data="{field:'product_name',align:'center',width:180}">商品</th>
                        <th lay-data="{field:'status_string',align:'center'}">订单状态</th>
                        <th lay-data="{field:'end_time',align:'center'}">合伙人到期时间</th>
                        <th lay-data="{field:'create_at',align:'center',width:180}">创建时间</th>
                        <th lay-data="{field:'pay_time',align:'center',width:180}">付款时间</th>
                    </tr>
                    </thead>
                </table>


        </div>
    </div>
</div>

<script type="text/html" id="toolbarUser" class="layer-photos-demo">
    <img src="@{{ d.user.avatar }}" width="30px" height="30px" layer-src="@{{ d.user.avatar }}" style="border-radius: 100%" alt="" lay-event="show">
    <span style="margin-left: 10px">@{{d.user.nick_name}}</span>
</script>



<script>
    layui.config({
        base: "/plugin/layuiadmin/"  //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table'], function(){
        var $ = layui.$,
            form = layui.form,
            table = layui.table;

        form.on('select(status)', function(data) {
            table.reload('order_table', {
                where:{
                    status:data.value
                }
            });
        });

        $("#search").on('click', function () {
            table.reload('order_table', {
                where:{
                    order_sn:$("#order_sn").val()
                }
            });
        });


        table.on('tool(order_table)', function(obj){
            var data = obj.data;
            var that = this;
            var url = $(this).data('url');

            switch (obj.event) {
                case "show":
                    var arr = [];
                    var obj = {
                        'alt':data.user.nick_name,
                        'pic':data.user.nick_name,
                        'src':data.user.avatar,
                        'thumb':data.user.avatar
                    };
                    arr.push(obj);
                    var json = {
                        'title':data.user.nick_name,
                        'id':data.id,
                        'start':0,
                        'data':arr
                    };
                    layer.photos({
                        photos: json
                        ,anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
                    });
                    break;


                case 'delete':
                    layer.confirm('是否确认删除', {
                        btn: ['取消','确认'], //按钮
                        title:'温馨提示'
                    }, function(){
                        layer.closeAll();
                    }, function(){
                        $.ajax({
                            url:url,
                            dateType:'json',
                            type:'post',
                            headers: {
                                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
                            },
                            success:function (res) {
                                layer.closeAll();
                                layer.msg(res.message);
                                table.reload('order_table')
                            }
                        });

                    });
                    break;

                default:
                    break;

            }

        });

    });

</script>
</body>

@include('admin._include.footer')


